import React, {useEffect, useState} from 'react';

function Child(){
    useEffect(()=>{
        console.log("挂载阶段：componentDidMount");
        return ()=>{
            console.log("卸载阶段：componentWillUnmount")
        }
    },[]);


    return (
        <div>
            <h3>Child</h3>
        </div>
    )
}
function App(props) {
    const [isShow,setIsShow] = useState(true);
    return (
        <div>
            <button onClick={()=>setIsShow(!isShow)}>显示与隐藏</button>
            {
                isShow && <Child/>
            }
        </div>
    );
}

export default App;